﻿using System.IO;
using WaveringLand_Launcher.Helper.Common;

namespace WaveringLand_Launcher.Model
{
    [PropertyChanged.AddINotifyPropertyChangedInterface]
    public class WllFile
    {
        public string Path { get; set; }
        public string MD5 { get; set; }
        public string Url { get; set; }

        /// <summary>
        /// 文件归类 Mods 模组 Resourcepacks 资源包 Shaderpacks 光影包 ServersDat 服务器dat文件
        /// </summary>
        public string Category { get; set; }
        
        public string Method { get; set; }

        public bool CheckNeedUpdate()
        {
            var truepath =(System.IO.Path.GetFullPath(Path));
            if (Directory.Exists(System.IO.Path.GetDirectoryName(truepath)) is false)
            {
                Directory.CreateDirectory(System.IO.Path.GetDirectoryName(truepath));
            }
            if (File.Exists(Path))
            {
                return Md5Helper.GetMd5(Path) == MD5?false:true;
            }
            else
            {
                return true;
            }
           
        }
    }
}